﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using NDK.WPF.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace NDK.WPF.ViewModels
{
    public class PLCSignalMonitorModel : ObservableObject
    {
        private ObservableCollection<PLCInPut> _ListPLCInPut = new ObservableCollection<PLCInPut>();

        public ObservableCollection<PLCInPut> ListPLCInPut
        {
            get { return _ListPLCInPut; }
            set { SetProperty(ref _ListPLCInPut, value); }
        }

        private ObservableCollection<PLCOutPut> _ListPLCOutPut = new ObservableCollection<PLCOutPut>();

        public ObservableCollection<PLCOutPut> ListPLCOutPut
        {
            get { return _ListPLCOutPut; }
            set { SetProperty(ref _ListPLCOutPut, value); }
        }

        private ICommand _Cmd_新增;

        public ICommand Cmd_新增
        {
            get
            {
                if(_Cmd_新增 == null)
                {
                    _Cmd_新增 = new RelayCommand<string>(str =>
                    {
                        if(str == "in")
                        {
                            ListPLCInPut.Add(new PLCInPut());
                        }
                        else
                        {
                            ListPLCOutPut.Add(new PLCOutPut());
                        }
                    });
                }
                return _Cmd_新增;
            }
        }

    }
}
